package com.example.mvvm.view;

import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;
import com.example.mvvm.viewModel.BaseViewModel;

public abstract class BaseActivity <VM extends BaseViewModel,VD extends ViewDataBinding> extends AppCompatActivity {
    protected VM mViewModel;
    protected VD mDataBinding;
    protected abstract int getLayoutId();
    protected abstract void init();
    protected abstract VM getViewModel();

    @Override
    protected void onCreate(@Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mViewModel = getViewModel();
        mDataBinding = DataBindingUtil.setContentView(this,getLayoutId());
        init();
    }
}
